/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    cn-hangzhou = 'linkedmall.aliyuncs.com',
    cn-shanghai = 'linkedmall.aliyuncs.com',
    ap-northeast-1 = 'linkedmall.aliyuncs.com',
    ap-northeast-2-pop = 'linkedmall.aliyuncs.com',
    ap-south-1 = 'linkedmall.aliyuncs.com',
    ap-southeast-1 = 'linkedmall.aliyuncs.com',
    ap-southeast-2 = 'linkedmall.aliyuncs.com',
    ap-southeast-3 = 'linkedmall.aliyuncs.com',
    ap-southeast-5 = 'linkedmall.aliyuncs.com',
    cn-beijing = 'linkedmall.aliyuncs.com',
    cn-beijing-finance-1 = 'linkedmall.aliyuncs.com',
    cn-beijing-finance-pop = 'linkedmall.aliyuncs.com',
    cn-beijing-gov-1 = 'linkedmall.aliyuncs.com',
    cn-beijing-nu16-b01 = 'linkedmall.aliyuncs.com',
    cn-chengdu = 'linkedmall.aliyuncs.com',
    cn-edge-1 = 'linkedmall.aliyuncs.com',
    cn-fujian = 'linkedmall.aliyuncs.com',
    cn-haidian-cm12-c01 = 'linkedmall.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'linkedmall.aliyuncs.com',
    cn-hangzhou-finance = 'linkedmall.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'linkedmall.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'linkedmall.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'linkedmall.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'linkedmall.aliyuncs.com',
    cn-hangzhou-test-306 = 'linkedmall.aliyuncs.com',
    cn-hongkong = 'linkedmall.aliyuncs.com',
    cn-hongkong-finance-pop = 'linkedmall.aliyuncs.com',
    cn-huhehaote = 'linkedmall.aliyuncs.com',
    cn-north-2-gov-1 = 'linkedmall.aliyuncs.com',
    cn-qingdao = 'linkedmall.aliyuncs.com',
    cn-qingdao-nebula = 'linkedmall.aliyuncs.com',
    cn-shanghai-et15-b01 = 'linkedmall.aliyuncs.com',
    cn-shanghai-et2-b01 = 'linkedmall.aliyuncs.com',
    cn-shanghai-finance-1 = 'linkedmall.aliyuncs.com',
    cn-shanghai-inner = 'linkedmall.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'linkedmall.aliyuncs.com',
    cn-shenzhen = 'linkedmall.aliyuncs.com',
    cn-shenzhen-finance-1 = 'linkedmall.aliyuncs.com',
    cn-shenzhen-inner = 'linkedmall.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'linkedmall.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'linkedmall.aliyuncs.com',
    cn-wuhan = 'linkedmall.aliyuncs.com',
    cn-yushanfang = 'linkedmall.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'linkedmall.aliyuncs.com',
    cn-zhangjiakou = 'linkedmall.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'linkedmall.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'linkedmall.aliyuncs.com',
    eu-central-1 = 'linkedmall.aliyuncs.com',
    eu-west-1 = 'linkedmall.aliyuncs.com',
    eu-west-1-oxs = 'linkedmall.aliyuncs.com',
    me-east-1 = 'linkedmall.aliyuncs.com',
    rus-west-1-pop = 'linkedmall.aliyuncs.com',
    us-east-1 = 'linkedmall.aliyuncs.com',
    us-west-1 = 'linkedmall.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('linkedmall', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AssignPermissionsToRoleRequest {
  permissionCodes?: map[string]any(name='PermissionCodes'),
  permissionIds?: map[string]any(name='PermissionIds'),
  roleCode?: string(name='RoleCode'),
  roleId?: string(name='RoleId'),
  tenantId?: string(name='TenantId'),
}

model AssignPermissionsToRoleShrinkRequest {
  permissionCodesShrink?: string(name='PermissionCodes'),
  permissionIdsShrink?: string(name='PermissionIds'),
  roleCode?: string(name='RoleCode'),
  roleId?: string(name='RoleId'),
  tenantId?: string(name='TenantId'),
}

model AssignPermissionsToRoleResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model AssignPermissionsToRoleResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AssignPermissionsToRoleResponseBody(name='body'),
}

async function assignPermissionsToRoleWithOptions(tmpReq: AssignPermissionsToRoleRequest, runtime: Util.RuntimeOptions): AssignPermissionsToRoleResponse {
  Util.validateModel(tmpReq);
  var request = new AssignPermissionsToRoleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.permissionCodes)) {
    request.permissionCodesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.permissionCodes, 'PermissionCodes', 'json');
  }
  if (!Util.isUnset(tmpReq.permissionIds)) {
    request.permissionIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.permissionIds, 'PermissionIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.permissionCodesShrink)) {
    query['PermissionCodes'] = request.permissionCodesShrink;
  }
  if (!Util.isUnset(request.permissionIdsShrink)) {
    query['PermissionIds'] = request.permissionIdsShrink;
  }
  if (!Util.isUnset(request.roleCode)) {
    query['RoleCode'] = request.roleCode;
  }
  if (!Util.isUnset(request.roleId)) {
    query['RoleId'] = request.roleId;
  }
  if (!Util.isUnset(request.tenantId)) {
    query['TenantId'] = request.tenantId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AssignPermissionsToRole',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function assignPermissionsToRole(request: AssignPermissionsToRoleRequest): AssignPermissionsToRoleResponse {
  var runtime = new Util.RuntimeOptions{};
  return assignPermissionsToRoleWithOptions(request, runtime);
}

model AssignResourcesToPermissionRequest {
  permissionCode?: string(name='PermissionCode'),
  permissionId?: string(name='PermissionId'),
  requestId?: string(name='RequestId'),
  resourceCodes?: map[string]any(name='ResourceCodes'),
  resourceIds?: map[string]any(name='ResourceIds'),
  tenantId?: string(name='TenantId'),
}

model AssignResourcesToPermissionShrinkRequest {
  permissionCode?: string(name='PermissionCode'),
  permissionId?: string(name='PermissionId'),
  requestId?: string(name='RequestId'),
  resourceCodesShrink?: string(name='ResourceCodes'),
  resourceIdsShrink?: string(name='ResourceIds'),
  tenantId?: string(name='TenantId'),
}

model AssignResourcesToPermissionResponseBody = {
  code?: string(name='Code'),
  isSuccess?: boolean(name='IsSuccess'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model AssignResourcesToPermissionResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AssignResourcesToPermissionResponseBody(name='body'),
}

async function assignResourcesToPermissionWithOptions(tmpReq: AssignResourcesToPermissionRequest, runtime: Util.RuntimeOptions): AssignResourcesToPermissionResponse {
  Util.validateModel(tmpReq);
  var request = new AssignResourcesToPermissionShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.resourceCodes)) {
    request.resourceCodesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.resourceCodes, 'ResourceCodes', 'json');
  }
  if (!Util.isUnset(tmpReq.resourceIds)) {
    request.resourceIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.resourceIds, 'ResourceIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.permissionCode)) {
    query['PermissionCode'] = request.permissionCode;
  }
  if (!Util.isUnset(request.permissionId)) {
    query['PermissionId'] = request.permissionId;
  }
  if (!Util.isUnset(request.requestId)) {
    query['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.resourceCodesShrink)) {
    query['ResourceCodes'] = request.resourceCodesShrink;
  }
  if (!Util.isUnset(request.resourceIdsShrink)) {
    query['ResourceIds'] = request.resourceIdsShrink;
  }
  if (!Util.isUnset(request.tenantId)) {
    query['TenantId'] = request.tenantId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AssignResourcesToPermission',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function assignResourcesToPermission(request: AssignResourcesToPermissionRequest): AssignResourcesToPermissionResponse {
  var runtime = new Util.RuntimeOptions{};
  return assignResourcesToPermissionWithOptions(request, runtime);
}

model CheckPermissionOfRoleRequest {
  permissionCode?: string(name='PermissionCode'),
  permissionId?: string(name='PermissionId'),
  requestId?: string(name='RequestId'),
  roleCode?: string(name='RoleCode'),
  roleId?: string(name='RoleId'),
  tenantId?: string(name='TenantId'),
}

model CheckPermissionOfRoleResponseBody = {
  code?: string(name='Code'),
  data?: boolean(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model CheckPermissionOfRoleResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CheckPermissionOfRoleResponseBody(name='body'),
}

async function checkPermissionOfRoleWithOptions(request: CheckPermissionOfRoleRequest, runtime: Util.RuntimeOptions): CheckPermissionOfRoleResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CheckPermissionOfRole',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function checkPermissionOfRole(request: CheckPermissionOfRoleRequest): CheckPermissionOfRoleResponse {
  var runtime = new Util.RuntimeOptions{};
  return checkPermissionOfRoleWithOptions(request, runtime);
}

model CreatePermissionRequest {
  actionType?: string(name='ActionType'),
  code?: string(name='Code'),
  description?: string(name='Description'),
  name?: string(name='Name'),
  permissionItemId?: string(name='PermissionItemId'),
  requestId?: string(name='RequestId'),
  tenantId?: string(name='TenantId'),
  type?: string(name='Type'),
  urlForApply?: string(name='UrlForApply'),
}

model CreatePermissionResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  permissionId?: string(name='PermissionId'),
  requestId?: string(name='RequestId'),
}

model CreatePermissionResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreatePermissionResponseBody(name='body'),
}

async function createPermissionWithOptions(request: CreatePermissionRequest, runtime: Util.RuntimeOptions): CreatePermissionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.actionType)) {
    query['ActionType'] = request.actionType;
  }
  if (!Util.isUnset(request.code)) {
    query['Code'] = request.code;
  }
  if (!Util.isUnset(request.description)) {
    query['Description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.permissionItemId)) {
    query['PermissionItemId'] = request.permissionItemId;
  }
  if (!Util.isUnset(request.requestId)) {
    query['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.tenantId)) {
    query['TenantId'] = request.tenantId;
  }
  if (!Util.isUnset(request.type)) {
    query['Type'] = request.type;
  }
  if (!Util.isUnset(request.urlForApply)) {
    query['UrlForApply'] = request.urlForApply;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreatePermission',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createPermission(request: CreatePermissionRequest): CreatePermissionResponse {
  var runtime = new Util.RuntimeOptions{};
  return createPermissionWithOptions(request, runtime);
}

model CreateResourceRequest {
  code?: string(name='Code'),
  content?: string(name='Content'),
  creator?: string(name='Creator'),
  description?: string(name='Description'),
  name?: string(name='Name'),
  requestId?: string(name='RequestId'),
  resourceAttributeList?: map[string]any(name='ResourceAttributeList'),
  tenantId?: string(name='TenantId'),
  type?: string(name='Type'),
}

model CreateResourceShrinkRequest {
  code?: string(name='Code'),
  content?: string(name='Content'),
  creator?: string(name='Creator'),
  description?: string(name='Description'),
  name?: string(name='Name'),
  requestId?: string(name='RequestId'),
  resourceAttributeListShrink?: string(name='ResourceAttributeList'),
  tenantId?: string(name='TenantId'),
  type?: string(name='Type'),
}

model CreateResourceResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  resourceId?: string(name='ResourceId'),
}

model CreateResourceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateResourceResponseBody(name='body'),
}

async function createResourceWithOptions(tmpReq: CreateResourceRequest, runtime: Util.RuntimeOptions): CreateResourceResponse {
  Util.validateModel(tmpReq);
  var request = new CreateResourceShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.resourceAttributeList)) {
    request.resourceAttributeListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.resourceAttributeList, 'ResourceAttributeList', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.code)) {
    query['Code'] = request.code;
  }
  if (!Util.isUnset(request.content)) {
    query['Content'] = request.content;
  }
  if (!Util.isUnset(request.creator)) {
    query['Creator'] = request.creator;
  }
  if (!Util.isUnset(request.description)) {
    query['Description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.requestId)) {
    query['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.resourceAttributeListShrink)) {
    query['ResourceAttributeList'] = request.resourceAttributeListShrink;
  }
  if (!Util.isUnset(request.tenantId)) {
    query['TenantId'] = request.tenantId;
  }
  if (!Util.isUnset(request.type)) {
    query['Type'] = request.type;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateResource',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createResource(request: CreateResourceRequest): CreateResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  return createResourceWithOptions(request, runtime);
}

model CreateRoleRequest {
  code?: string(name='Code'),
  description?: string(name='Description'),
  extendRoleIds?: map[string]any(name='ExtendRoleIds'),
  mutexRoleIds?: map[string]any(name='MutexRoleIds'),
  name?: string(name='Name'),
  requestId?: string(name='RequestId'),
  tenantId?: string(name='TenantId'),
}

model CreateRoleShrinkRequest {
  code?: string(name='Code'),
  description?: string(name='Description'),
  extendRoleIdsShrink?: string(name='ExtendRoleIds'),
  mutexRoleIdsShrink?: string(name='MutexRoleIds'),
  name?: string(name='Name'),
  requestId?: string(name='RequestId'),
  tenantId?: string(name='TenantId'),
}

model CreateRoleResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  roleId?: string(name='RoleId'),
}

model CreateRoleResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateRoleResponseBody(name='body'),
}

async function createRoleWithOptions(tmpReq: CreateRoleRequest, runtime: Util.RuntimeOptions): CreateRoleResponse {
  Util.validateModel(tmpReq);
  var request = new CreateRoleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.extendRoleIds)) {
    request.extendRoleIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.extendRoleIds, 'ExtendRoleIds', 'json');
  }
  if (!Util.isUnset(tmpReq.mutexRoleIds)) {
    request.mutexRoleIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.mutexRoleIds, 'MutexRoleIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.code)) {
    query['Code'] = request.code;
  }
  if (!Util.isUnset(request.description)) {
    query['Description'] = request.description;
  }
  if (!Util.isUnset(request.extendRoleIdsShrink)) {
    query['ExtendRoleIds'] = request.extendRoleIdsShrink;
  }
  if (!Util.isUnset(request.mutexRoleIdsShrink)) {
    query['MutexRoleIds'] = request.mutexRoleIdsShrink;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.requestId)) {
    query['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.tenantId)) {
    query['TenantId'] = request.tenantId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateRole',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createRole(request: CreateRoleRequest): CreateRoleResponse {
  var runtime = new Util.RuntimeOptions{};
  return createRoleWithOptions(request, runtime);
}

model QueryAllPermissionOfRoleRequest {
  roleCode?: string(name='RoleCode'),
  roleId?: string(name='RoleId'),
  tenantId?: string(name='TenantId'),
}

model QueryAllPermissionOfRoleResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  permissionList?: [ 
    {
      code?: string(name='Code'),
      description?: string(name='Description'),
      name?: string(name='Name'),
      permissionId?: string(name='PermissionId'),
      permissionItemList?: [ 
        {
          actionType?: string(name='ActionType'),
          permissionItemId?: string(name='PermissionItemId'),
          permissionType?: string(name='PermissionType'),
        }
      ](name='PermissionItemList'),
    }
  ](name='PermissionList'),
  requestId?: string(name='RequestId'),
}

model QueryAllPermissionOfRoleResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryAllPermissionOfRoleResponseBody(name='body'),
}

async function queryAllPermissionOfRoleWithOptions(request: QueryAllPermissionOfRoleRequest, runtime: Util.RuntimeOptions): QueryAllPermissionOfRoleResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryAllPermissionOfRole',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryAllPermissionOfRole(request: QueryAllPermissionOfRoleRequest): QueryAllPermissionOfRoleResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryAllPermissionOfRoleWithOptions(request, runtime);
}

model QueryAllResourcesWithPermissionsRequest {
  tenantId?: string(name='TenantId'),
}

model QueryAllResourcesWithPermissionsResponseBody = {
  code?: string(name='Code'),
  data?: [ 
    {
      code?: string(name='Code'),
      content?: string(name='Content'),
      creator?: string(name='Creator'),
      description?: string(name='Description'),
      name?: string(name='Name'),
      permissionOfResourceList?: [ 
        {
          code?: string(name='Code'),
          description?: string(name='Description'),
          name?: string(name='Name'),
          permissionId?: string(name='PermissionId'),
          permissionItemList?: [ 
            {
              actionType?: string(name='ActionType'),
              permissionItemId?: string(name='PermissionItemId'),
              permissionType?: string(name='PermissionType'),
            }
          ](name='PermissionItemList'),
        }
      ](name='PermissionOfResourceList'),
      resourceAttributeList?: [  map[string]any ](name='ResourceAttributeList'),
      resourceId?: string(name='ResourceId'),
      type?: string(name='Type'),
    }
  ](name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model QueryAllResourcesWithPermissionsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryAllResourcesWithPermissionsResponseBody(name='body'),
}

async function queryAllResourcesWithPermissionsWithOptions(request: QueryAllResourcesWithPermissionsRequest, runtime: Util.RuntimeOptions): QueryAllResourcesWithPermissionsResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryAllResourcesWithPermissions',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryAllResourcesWithPermissions(request: QueryAllResourcesWithPermissionsRequest): QueryAllResourcesWithPermissionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryAllResourcesWithPermissionsWithOptions(request, runtime);
}

model QueryPermissionsRequest {
  resourceCode?: string(name='ResourceCode'),
  resourceId?: string(name='ResourceId'),
  roleCode?: string(name='RoleCode'),
  roleId?: string(name='RoleId'),
  tenantId?: string(name='TenantId'),
}

model QueryPermissionsResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  permissionItemList?: [ 
    {
      actionType?: string(name='ActionType'),
      permissionItemId?: string(name='PermissionItemId'),
      permissionType?: string(name='PermissionType'),
    }
  ](name='PermissionItemList'),
  permissionList?: [ 
    {
      code?: string(name='Code'),
      description?: string(name='Description'),
      name?: string(name='Name'),
      permissionId?: string(name='PermissionId'),
    }
  ](name='PermissionList'),
  requestId?: string(name='RequestId'),
}

model QueryPermissionsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryPermissionsResponseBody(name='body'),
}

async function queryPermissionsWithOptions(request: QueryPermissionsRequest, runtime: Util.RuntimeOptions): QueryPermissionsResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryPermissions',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryPermissions(request: QueryPermissionsRequest): QueryPermissionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryPermissionsWithOptions(request, runtime);
}

model QueryRolesByPartialRoleCodeRequest {
  partialRoleCode?: string(name='PartialRoleCode'),
  tenantId?: string(name='TenantId'),
}

model QueryRolesByPartialRoleCodeResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  roleList?: [ 
    {
      code?: string(name='Code'),
      description?: string(name='Description'),
      name?: string(name='Name'),
      roleId?: string(name='RoleId'),
    }
  ](name='RoleList'),
}

model QueryRolesByPartialRoleCodeResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryRolesByPartialRoleCodeResponseBody(name='body'),
}

async function queryRolesByPartialRoleCodeWithOptions(request: QueryRolesByPartialRoleCodeRequest, runtime: Util.RuntimeOptions): QueryRolesByPartialRoleCodeResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryRolesByPartialRoleCode',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryRolesByPartialRoleCode(request: QueryRolesByPartialRoleCodeRequest): QueryRolesByPartialRoleCodeResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryRolesByPartialRoleCodeWithOptions(request, runtime);
}

model RemovePermissionsOfRoleRequest {
  permissionCodes?: map[string]any(name='PermissionCodes'),
  permissionIds?: map[string]any(name='PermissionIds'),
  roleCode?: string(name='RoleCode'),
  roleId?: string(name='RoleId'),
  tenantId?: string(name='TenantId'),
}

model RemovePermissionsOfRoleShrinkRequest {
  permissionCodesShrink?: string(name='PermissionCodes'),
  permissionIdsShrink?: string(name='PermissionIds'),
  roleCode?: string(name='RoleCode'),
  roleId?: string(name='RoleId'),
  tenantId?: string(name='TenantId'),
}

model RemovePermissionsOfRoleResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model RemovePermissionsOfRoleResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RemovePermissionsOfRoleResponseBody(name='body'),
}

async function removePermissionsOfRoleWithOptions(tmpReq: RemovePermissionsOfRoleRequest, runtime: Util.RuntimeOptions): RemovePermissionsOfRoleResponse {
  Util.validateModel(tmpReq);
  var request = new RemovePermissionsOfRoleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.permissionCodes)) {
    request.permissionCodesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.permissionCodes, 'PermissionCodes', 'json');
  }
  if (!Util.isUnset(tmpReq.permissionIds)) {
    request.permissionIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.permissionIds, 'PermissionIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.permissionCodesShrink)) {
    query['PermissionCodes'] = request.permissionCodesShrink;
  }
  if (!Util.isUnset(request.permissionIdsShrink)) {
    query['PermissionIds'] = request.permissionIdsShrink;
  }
  if (!Util.isUnset(request.roleCode)) {
    query['RoleCode'] = request.roleCode;
  }
  if (!Util.isUnset(request.roleId)) {
    query['RoleId'] = request.roleId;
  }
  if (!Util.isUnset(request.tenantId)) {
    query['TenantId'] = request.tenantId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RemovePermissionsOfRole',
    version = '2021-06-16',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function removePermissionsOfRole(request: RemovePermissionsOfRoleRequest): RemovePermissionsOfRoleResponse {
  var runtime = new Util.RuntimeOptions{};
  return removePermissionsOfRoleWithOptions(request, runtime);
}

